package com.example.springmvc;

import com.example.springmvc.pojo.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class LoginController {

  @RequestMapping("/login")
  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView mav = new ModelAndView("login");
    return mav;
  }

  @RequestMapping(path = "/api/login", method = RequestMethod.GET)
  public ModelAndView getParam(User user) {
    ModelAndView mav = new ModelAndView("redirect:/springmvc/hello");
    System.out.println(user.getUserName());
    System.out.println(user.getPassword());
    mav.addObject("message", "login success");
    return mav;
  }
}
